//
// Created by xili on 2024/8/18 16:31.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int splitNum(int num) {
        vector<int> v;
        while (num) {
            v.push_back(num % 10);
            num /= 10;
        }
        sort(v.begin(), v.end());
        int num1 = 0, num2 = 0;
        int n = v.size();
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (flag) {
                num1 = num1 * 10 + v[i];
                flag = false;
            } else {
                num2 = num2 * 10 + v[i];
                flag = true;
            }
        }
        return num1 + num2;
    }
};